home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
003
/
db3_hdr.doc
< prev
next >
Wrap
Text File
|
1987-02-24
|
4KB
|
88 lines
.DBF and .NDX Header Definitions
Compiled by Curtis H. Hoffmann, 02/20/87.
If you find any errors or omissions, let me know on Terraboard (612)-721-8967.
.DBF Primary Header
-------------------
Address Contents Description
------- -------- -----------
0 1 byte Database type: 03 if data; 83 if there is an
associated memo file
1-3 3 ASCII char. Date last updated, in YY,MM,DD format
4-7 32 bit # Number of records in file
8-9 16 bit # Starting location of data
10-11 16 bit # Length of records (total field size +1)
12-31 20 bytes (Reserved)
32-n 32 bytes ea. Field descripter array
n+1 1 byte 0D hex terminator
.DBF Field Descripter Array
---------------------------
0 1 byte Deletion marker; 2A if marked else 20 hex
1-10 10 bytes Field name in ASCII (0 as terminator)
11 1 byte Field type in ASCII
12-15 32 bit # Field data address (internal use)
16 1 byte Field length in binary
17 1 byte Field decimal count in binary
18-31 14 bytes (reserved)
=======================================================================
.NDX Anchor Node Heading
------------------------
Address Contents Description
------- -------- -----------
0-1 2 bytes (Reserved)
4-5 16 bit # Node number of root node
8-9 16 bit # Node number of next available node
12 1 byte Length of key in binary
14 1 byte Maximum number of keys per 512 byte node
16 1 byte Index key type; 0 if character key, else 01
18 1 byte length of key records in binary (includes address
to .DBF file)
24-279 256 bytes Key expression in ASCII (00 hex as terminator)
280-511 232 bytes (Unused)
.NDX Array (all other nodes)
----------------------------
0 1 byte Number of records in this node
4-7 32 bit # Identifies type of node; 0 if a leaf else the node
number of the next branch of the tree
8-11 32 bit # If not a branch then this is the address to the
corresponding .DBF record
12-n mod 8 bytes Key expression
n+1-512 record length Repeating addresses and key expressions until the
end of the node
Every node is 512 bytes long, treated as part of a B+ tree. If the node
is a branch, then compare the match pattern with the key expression. If the
pattern <= the key, then go to the appropriate lower lever node, otherwise
go to the next key in that node. Do this only for the number of keys in this
node.
Algorithm for finding a given record:
-------------------------------------
A) Read starting node # (SN), length of key (LOK), length of key
record (LOKR), and total number of nodes (TON).
B) Goto starting node (SN*512). Check to see if the node is a leaf or a
branch (addresses 4 through 7 = 0 if leaf). Current node (CN) = SN
C) Get number of records for this node (NOR). Zero pointer. <--
D) While current node < TON and desired record not found, do: |
While pointer <= NOR and record not found, do: |
piece key expression together. |
cs=512*CN+12+(pointer-1)*LOKR. |
if match pattern <= key expression, do: |
if branch then CN=contents at cs+4. Repeat ---------
if not branch and match pattern=key then, do: |
data field record at cs+8. |
** Done ** |
else increment pointer |
If end of node and match not made, do: |
If branch, current node = contents of cs+4. Repeat ----
If not branch, then record not in index. ** Done **